/*
 *
 * **/
var channel = {};
channel.getAppName = function(){
	return "Channel Web";
}
channel.defaultUrl = function(){
	return '/channel?t='+new Date().getTime();
}
//obj : {masker,url,params,scope,method}
channel.openLink = function(obj){
	obj = typeof obj == 'object' ? obj : {};
	if(obj.masker){
		obj.masker.el.mask('Please wait...','openLinkLoading');
	}
	Ext.Ajax.request({
		url:obj.url || channel.defaultUrl,
		params:obj.params || {e:''},
		method:obj.method || 'post',
		success:function(response,opts){
			if(obj.masker){
				obj.masker.el.unmask();
			}
			var rs = response.responseText?Ext.decode(response.responseText):{};
			rs = rs.channelResult;
			if(rs.success){
				if(Ext.isFunction(obj.onSuccess)){
					Ext.Function.bind(obj.onSuccess,obj.scope||window,[rs,opts])();
				}
			}else{
				Ext.Msg.show({
					title:'Message',
					msg:rs.msg||'Error',
					width:280,
					buttons:Ext.Msg.OK,
					icon:Ext.Msg.WARING,
					scop:obj.scope,
					closable:false,
					fn:function(btn){
						if(Ext.isFunction(obj.onFailure)){
							Ext.Function.bind(obj.onFailure,obj.scope||window,[rs,opts,btn])();
						}
					}
				});
			}
		},
		failure:function(response,opts){
			if(obj.masker){
				obj.masker.el.unmask();
			}
			var rs = response.responseText?Ext.decode(response.responseText):{};
			rs = rs.channelResult;
			Ext.Msg.show({
				title:'Message',
				msg:rs.msg||'Error',
				width:280,
				buttons:Ext.Msg.OK,
				icon:Ext.Msg.WARING,
				scop:obj.scope,
				closable:false,
				fn:function(btn){
					if(Ext.isFunction(obj.onFailure)){
						Ext.Function.bind(obj.onFailure,obj.scope||window,[rs,opts,btn])();
					}
				}
			});
		}
	});
}
channel.printObj = function(obj){
	var str = '<table border=1>';
		for (var i in thiz)
		{
		    str += '<tr><td>' + i + ' </td><td> ' + thiz[i] + '</td></tr>';
		    i++;
		}
		str += '</table>';
	return str;
}


//ExtJs Config
Ext.Ajax.timeout = 60000*3;
Ext.BLANK_IMAGE_URL = (Ext.isIE6 || Ext.isIE7) ? '/style/common/extjs4/resources/s.gif' : '';
Ext.form.field.Base.prototype.msgTarget = 'side';
Ext.tip.QuickTipManager.init();
